package com.cty.util;

public class ServerResult {
    private int code;
    private String reason;
    private Object data;

    // get,set 
    // constructor
    public ServerResult(){}
    public ServerResult(int code, String reason, Object data) {
        this.code = code;
        this.reason = reason;
        this.data = data;
    }

    //查询成功
    public static ServerResult getSuccess(Object data){
        return new ServerResult(200,"查询数据成功",data);
    }
    public static ServerResult getFail(Object data){
        return new ServerResult(201,"查询数据失败",data);
    }
    public static ServerResult saveSuccess(Object data){
        return new ServerResult(200,"添加数据成功",data);
    }
    public static ServerResult saveFail(Object data){
        return new ServerResult(201,"添加数据失败",data);
    }
    public static ServerResult updateSuccess(Object data){
        return new ServerResult(200,"修改数据成功",data);
    }
    public static ServerResult updateFail(Object data){
        return new ServerResult(201,"修改数据失败",data);
    }
    public static ServerResult deleteSuccess(Object data){
        return new ServerResult(200,"删除数据成功",data);
    }
    public static ServerResult deleteFail(Object data){
        return new ServerResult(201,"删除数据失败",data);
    }
    public static ServerResult loginSuccess(Object data){
        return new ServerResult(200,"登录成功",data);
    }
    public static ServerResult loginFail(Object data){
        return new ServerResult(201,"登录失败",data);
    }




    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ServerResult{" +
                "code=" + code +
                ", reason='" + reason + '\'' +
                ", data=" + data +
                '}';
    }
}
